﻿using Protocol.Dto;
using Script.Model;

namespace Script.UI._2.Fight
{
    public class RightStatePanel : StatePanel
    {
        protected override void Awake()
        {
            base.Awake();

            Bind(UIEvent.SET_RIGHT_PLAYER_DATA);
        }

        protected override void Start()
        {
            base.Start();

            if (Models.GameModel.GetRightUserId() != -1)
            {
                userDto = Models.GameModel.MatchRoomDto.UIdUserDict[Models.GameModel.GetRightUserId()];

                if (Models.GameModel.MatchRoomDto.ReadyUIdList.Contains(Models.GameModel.MatchRoomDto.RightId))
                {
                    ReadyState();
                }
            }
            else
            {
                SetPanelActive(false);
            }
        }

        public override void Execute(int eventCode, object message)
        {
            base.Execute(eventCode, message);
            switch (eventCode)
            {
                case UIEvent.SET_RIGHT_PLAYER_DATA:
                    userDto = message as UserDto;
                    break;
            }
        }
    }
}